package com.weblog.controller.weblog;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.weblog.model.user.User;

/**
 * 博客控制器
 * 
 * @author zhw
 *
 */
@Controller
@RequestMapping(value = "/weblog")
public class WeblogController {

	/**
	 * 博客主页，显示文章最多的分类前8个，然后最新发布的文章
	 * 
	 * @param model
	 * @return
	 */
	@RequestMapping(value = "/index")
	public String weblogIndex(Model model) {
		Subject subject = SecurityUtils.getSubject();
		if (subject.isAuthenticated()) {
			String userName = (String) subject.getPrincipal();
			model.addAttribute("username", userName);
		}
		return "/weblog/index";
	}

}
